package Lee_code;

public class Lee_724 {
    public static int pivotIndex(int[] nums) {

        int index = -1;
        int sum_left = 0;
        int sum_right = 0;
        for(int i = 0; i<nums.length; i++)
        {
            //重置一下
            sum_right = 0;
            sum_left = 0;
            //计算左边的和
            for(int j=0; j<i; j++)
            {
                sum_left = sum_left + nums[j];
            }
            //计算右边的和
            for(int j = nums.length-1; j>i; j--)
            {
                sum_right = sum_right + nums[j];
            }

//            System.out.println("i是:"+i);
//            System.out.println(sum_left);
//            System.out.println(sum_right);
//            System.out.println();
            if(sum_right==sum_left)
            {
                index=i;
                break;
            }
        }

        return index;
    }
    public static void main(String[] args)
    {
        int[] a = {1, 7, 3, 6, 5, 6};
        System.out.println(pivotIndex(a));
    }
}
